IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'CreatorGet')
	BEGIN
		DROP  Procedure  CreatorGet
	END

GO

CREATE Procedure CreatorGet
@CreatorID Int
AS
Select 
c.CreatorID,
c.DefaultSagaID,
c.IsBrowser,
c.CanAdd,
asp.UserName,
coalesce (r.RoleName,'Browser') RoleName,
coalesce (r.SagaRoleID,1) SagaRoleID
From Creator c
Join aspnet_Users asp On asp.UserID = c.UserID
Left Join  aspnet_UsersInRoles ri On ri.UserID = asp.UserID
Left Join SagaCreators sc On sc.CreatorID = c.CreatorID and sc.SagaId = c.DefaultSagaID
Left Join SagaRoles r on r.SagaRoleID = sc.SagaRoleID 
Where c.CreatorID = @CreatorID

GO



